/*      *************************************************************       */
/* This is just a short example of implementing a MySql DB connection       */ 
/* with Java. You need to include the MySQL Java connector                  */
/* created by Martin Stoppacher     26.12.2009                              */
/*    *****************************************************************     */

import java.sql.*;^M
^M
public class 1_MySql_connector {^M
^M
    public static void main(String[] args) {^M
^M
    String uid = "root";^M
    String url = "jdbc:mysql://localhost/test";
    String uid = "root";
    String pwd = "password";^M
^M
    try {^M
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());^M
      Connection conn = DriverManager.getConnection(url, uid, pwd);^M
      Statement stmt = conn.createStatement ();        ^M
         ResultSet rset1 =^M
         stmt.executeQuery("select max(Nr)+1 as maximum from mytest");^M
         rset1.next();^M
         int i=rset1.getInt("maximum");^M
         //ResultSet rset1 =^M
         stmt.executeUpdate("insert into mytest values("+i+",\'Java\')");^M
         ResultSet rset2 =^M
         stmt.executeQuery("select NR, NAME from mytest");^M
               System.out.println("NR______NAME");^M
         while (rset2.next()) {^M
         System.out.print(rset2.getString("nr"));^M
         System.out.print("_____");^M
         System.out.println(rset2.getString("NAME"));^M
         }^M
        System.out.println("END");^M
^M
    } catch (SQLException e) {^M
      System.out.println(e);^M
    }^M
  }^M
}